package me.numark.model;

import com.google.gson.Gson;

import java.util.Date;
import java.util.List;

/**
 * Created by tian on 14/11/6:上午8:18.
 */
public class Feed extends BaseModel {


    public int label_num;
    public int position;

    public int r_status;

    public String c_type;

    public long mid;

    public int type;

    public int status;

    public String description;

    public Feed mark;

    public int nsid;

    public String create;

    public int comments;

    public Forward forward;

    public int like;

    public long create_timestamp;

    public User user;

    public News news;

    public List<FeedTag> labels;

    public boolean is_like;

    public User[] forward_person;

    public static final int FEED_TYPE_MINE = 0;

    public static final int FEED_TYPE_HOT = 1;

    public boolean is_mine;

   // public Topic topic;

    public Feed reply_topic;

    public int commentType;

    public int likeType;


    ///////////////////自己加的字段 用于广播同步数据
    public FeedTag updateFeedTag;

    public FeedTag deleteFeedTag;

    public FeedTag addFeedTag;

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof Feed))
            return false;
        Feed that = (Feed) o;
        if (that.forward == null && this.forward != null)
            return false;
        if (that.forward != null && this.forward == null)
            return false;
        if (that.forward != null && this.forward != null && that.forward.id != this.forward.id)
            return false;
        return (mid == that.mid) && (create_timestamp == that.create_timestamp);
    }

    @Override
    public String toString() {
        Gson gson = new Gson();
        return gson.toJson(this);
    }

    public Date getDate() {
        return new Date(create_timestamp * 1000);
    }

    public static Feed fromString(String string) {
        return new Gson().fromJson(string, Feed.class);
    }
}
